package com.yckj.activechicken.business.purchase.service.impl;

import com.yckj.activechicken.business.common.mapper.CustomSequenceMapper;
import com.yckj.activechicken.business.purchase.mapper.PurTaskMapper;
import com.yckj.activechicken.business.purchase.mapper.comp.PurTaskMapperComp;
import com.yckj.activechicken.business.purchase.model.PurTask;
import com.yckj.activechicken.business.purchase.model.vo.PurTaskVo;
import com.yckj.activechicken.business.purchase.service.IPurTaskService;
import com.yckj.activechicken.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * Title:com.yckj.activechicken.business.purchase.service.impl
 * </p>
 * <p/>
 * <p>
 * Description: 描述【采购任务单管理业务处理实例】
 * </p>
 * <p/>
 * <p>
 * Copyright: Copyright (c) 2019
 * </p>
 * <p/>
 * <p>
 * Company: 英才汇硕信息技术有限公司
 * </p>
 *
 * @author zhoujy
 * @version 1.0
 * @created 2020/6/18 17:30
 */
@Service
public class PurTaskServiceImpl implements IPurTaskService{
    @Autowired
    private CustomSequenceMapper customSequenceMapper;

    @Autowired
    private PurTaskMapperComp purTaskMapperComp;

    @Autowired
    private PurTaskMapper purTaskMapper;


    /**
     * 多条件查询采购任务单
     * @param purTaskVo
     * @return
     */
    @Override
    public List<PurTaskVo> queryPurTaskList(PurTaskVo purTaskVo) {
        return purTaskMapperComp.selectPurTaskList(purTaskVo);
    }

    /**
     * 添加采购任务单
     * @param purTask
     * @return
     */
    @Override
    public int addPurTask(PurTask purTask) {
        String purTaskId = customSequenceMapper.selectNextVal("pur_task_id");
        purTask.setPurTaskId(purTaskId);
        if(StringUtils.equals(purTask.getStatus(),"下发未认领")){
            purTask.setAssignTime(purTask.getCreateTime());
        }
        return purTaskMapper.insertSelective(purTask);
    }
}
